package pers.xx.sbm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import pers.xx.sbm.entity.JfFile;
import pers.xx.sbm.entity.JfInfo;
import pers.xx.sbm.enums.ResultEnum;
import pers.xx.sbm.service.JfFileService;
import pers.xx.sbm.service.JfInfoService;
import pers.xx.sbm.vo.ResResult;

import java.util.List;

/**
 * @author ：xiexing
 * @description：教辅调研
 * @date ：2021/1/27 11:06
 */
@Controller
@RequestMapping("/gyeducation/api")
public class BookNavigation {

    @Autowired
    private JfInfoService jfInfoService;

    @Autowired
    private JfFileService jfFileService;

    /**
     * @description 系统未登录首页
     * @author XieXing
     * @date 2020/12/1 14:08
     */
    @RequestMapping("/jfInformation")
    public String bookNavigation() {
        return "page/book_navigation/bookInvestigationNew";
    }


    /**
     * @description 跳转到教辅列表
     * @author XieXing
     * @date 2021/2/7 17:46
     */
    @RequestMapping("/list")
    public String list() {
        return "/page/book_navigation/list";
    }

    /**
     * @description 获取菜单列表
     * @author XieXing
     * @date 2020/8/12 14:52
     */
    @RequestMapping("/getDataList")
    @ResponseBody
    public ResResult getDataList(JfInfo jfInfo, Integer page, Integer limit, String searchContent) {
        if (!StringUtils.isEmpty(searchContent)) {
            jfInfo.setMaterialsName(searchContent);//临时添加
        }
        ResResult resResult = jfInfoService.listByPage(jfInfo, page, limit);
        resResult.setOptName("获取操作日志列表");
        return resResult;
    }

    /**
     * @description 获取文件数据列表
     * @author XieXing
     * @date 2021/2/8 10:27
     */
    @RequestMapping("/getFileDataList")
    @ResponseBody
    public ResResult getFileDataList(String id) {
        ResResult resResult = new ResResult();
        List<JfFile> jfFiles = jfFileService.getJfFilesById(id);
        resResult.setResult(ResultEnum.SUCCESS, jfFiles);
        resResult.setOptName("获取操作日志列表");
        return resResult;
    }
}
